<template>
	<view class="content-wraper" :class="{ pt0: activeBarIdx != 0 }">
		<view class="get-page" v-show="activeBarIdx == 0">
			<view class="login-logo">
				<view class="logo-wrap">
					<image class="logo" src="/static/images/test01.jpg"></image>
				</view>
				<view class="user-name">
					<text class="name">小柏佰</text>
					<text class="state">已登录</text>
				</view>
			</view>
			<uni-notice-bar showIcon="true" background-color="#C9DBFC" scrollable="true" showClose="true" single="true" speed="20"
			 :text="notice"></uni-notice-bar>
			<view class="panel-box main-header-panel-box">
				<view class="panel-head">
					<view class="hd-inner">
						<text class="tit">本月收益</text>
					</view>
				</view>
				<view class="panel-body">
					<view class="panel-bd-inner">
						<view class="yellow-text-component">
							<text class="t-yellow">+0.00000052</text>
							<text class="t-black">ETH</text>
						</view>
					</view>
				</view>
				<view class="panel-footer">
					<view class="panel-footer-inner">
						<view class="icon-text-component">
							<text class="iconfont iconyingyongicon- icon"></text>
							<text class="text">今日币价：</text>
							<text class="num-m">￥19999</text>
						</view>
						<view class="line"></view>
						<view class="icon-text-component">
							<text class="iconfont iconhuiyuanfazhanqushi icon"></text>
							<text class="text">今日涨幅：</text>
							<text class="num-bg">16.88%</text>
						</view>
					</view>
				</view>
			</view>
			<getList :listData="achiveItems" @slide="slideToggle"></getList>
			<xw-empty v-if="achiveItems.length == 0" :isShow="true" text="暂无数据" textColor="#777777"></xw-empty>
			<uni-load-more v-if="achiveItems.length > 0" :status="msgMoreStatus" iconType="snow"></uni-load-more>
		</view>
		<view class="my-page" v-show="activeBarIdx == 1">
			<my></my>
		</view>
		<view class="footer-bar">
			<view class="nav-item" :class="{active: activeBarIdx == 0 }" @tap="changeTab(0)">
				<text class="iconfont iconqianbao nav-icon"></text>
				<text class="text">收益</text>
			</view>
			<view class="nav-item" :class="{active: activeBarIdx == 1 }" @tap="changeTab(1)">
				<text class="iconfont icongerenzhongxin nav-icon"></text>
				<text class="text">我的</text>
			</view>
		</view>
	</view>

</template>

<script>
	import getList from '@/components/get-list/get-list.vue'
	import my from '@/components/my/my.vue'
	import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue'
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import xwEmpty from '@/components/xw-empty/xw-empty.vue';
	export default {
		components: {
			uniNoticeBar,
			getList,
			my,
			uniLoadMore,
			xwEmpty,
		},
		data() {
			return {
				activeBarIdx: 0, // 当前点击的底部nav索引，0,1分别是收益和我的
				msgMoreStatus: 'loading', // 底部加载更多提示more（loading前）、loading（loading中）、noMore（没有更多了）
				notice: '这里是公告这里是公告这里是公告这里是公告这里是公告这里是公告这里是公告这里是公告', // 公告内容
				achiveItems: [{
						isSlide: true,
						title: '2020-09-11',
						sjsy: {
							name: '实际收益',
							num: '+0.00000052',
							tag: '（ETH）'
						},
						yssy: {
							name: '应收益',
							num: '+0.00000052',
							tag: ''
						},
						glf: {
							name: '管理费',
							num: '0.00000052',
							tag: ''
						},
						df: {
							name: '电费',
							num: '0.00000052',
							tag: ''
						},
						sl: {
							name: '算力',
							num: '2T',
							tag: ''
						}
					},
					{
						isSlide: true,
						title: '2020-09-11',
						sjsy: {
							name: '实际收益',
							num: '+0.00000052',
							tag: '（ETH）'
						},
						yssy: {
							name: '应收益',
							num: '+0.00000052',
							tag: ''
						},
						glf: {
							name: '管理费',
							num: '0.00000052',
							tag: ''
						},
						df: {
							name: '电费',
							num: '0.00000052',
							tag: ''
						},
						sl: {
							name: '算力',
							num: '2T',
							tag: ''
						}
					},
					{
						isSlide: true,
						title: '2020-09-11',
						sjsy: {
							name: '实际收益',
							num: '+0.00000052',
							tag: '（ETH）'
						},
						yssy: {
							name: '应收益',
							num: '+0.00000052',
							tag: ''
						},
						glf: {
							name: '管理费',
							num: '0.00000052',
							tag: ''
						},
						df: {
							name: '电费',
							num: '0.00000052',
							tag: ''
						},
						sl: {
							name: '算力',
							num: '2T',
							tag: ''
						}
					}
				]

			}
		},
		onPullDownRefresh() { // 下拉刷新函数
			if (this.activeBarIdx == 0) { // 收益显示的时候才执行
				console.log('下拉刷新啦======');
				setTimeout(() => {
					uni.stopPullDownRefresh(); // 停止下拉刷新
				}, 2000)
			}

		},
		onReachBottom() {
			if (this.activeBarIdx == 0) { // 收益显示的时候才执行
				console.log('滚动到底部加载更多');
				this.msgMoreStatus = 'loading'; // 加载数据时，置为loading
				setTimeout(() => {
					this.msgMoreStatus = 'noMore'; // 没有更多了
				}, 3000)
			}

		},
		onLoad() {
			uni.hideHomeButton(); // 隐藏首页按钮
			uni.startPullDownRefresh(); //  开始下拉刷新
		},
		methods: {
			slideToggle(i) { /* 展开收起 */
				this.achiveItems[i].isSlide = !this.achiveItems[i].isSlide;
			},
			changeTab(i) { // 切换tab显示
				this.activeBarIdx = i;
				switch (i) {
					case 0:
						uni.setNavigationBarTitle({
							title: '运算力收益ETH'
						});
						break;
					case 1:
						uni.setNavigationBarTitle({
							title: ''
						});
						break;
					default:
						break;
				}

			}

		}
	}
</script>

<style lang="scss">
	.pt0 {
		padding: 0 !important;
	}

	.content-wraper {
		padding: 30rpx;
		padding-bottom: calc(150rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		padding-bottom: calc(150rpx + env(safe-area-inset-bottom)); //兼容 IOS>11.2/
		min-height: 100vh;
		background-color: #f8f8f8;
		overflow: hidden;
	}


	.get-page {



		.login-logo {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			width: 750rpx;
			margin-bottom: 30rpx;

			.logo-wrap {
				width: 90rpx;
				height: 90rpx;
				border-radius: 50%;
				overflow: hidden;
				background: white;
			}

			.logo {
				width: 100%;
				height: 100%;
				border-radius: 50%;

			}

			.user-name {
				display: flex;
				flex: 1;
				width: 100%;
				align-items: center;
				font-size: 50rpx;

				.name {
					margin: 0 20rpx 0 25rpx;
				}

				.state {
					font-size: 24rpx;
					padding: 5rpx 30rpx;
					border-radius: 20rpx;
					color: white;
					background-color: #1166f5;
				}
			}
		}

		.panel-box {
			margin: 20rpx 0;
			background-color: white;
			border-radius: 16rpx;
			box-shadow: -2rpx 2rpx 6rpx rgba(0, 0, 0, .06);
		}

		.panel-head {
			display: flex;
			align-items: center;

			.hd-inner {
				flex: 1;
				display: flex;
				margin-right: 20rpx;
				padding: 30rpx 0;
				border-bottom: 2px solid #eee;
			}

			.tit {
				flex: 1;
				font-size: 30rpx;
				color: #444444;
				font-weight: bold;
			}

			.line {
				display: inline-block;
				margin-right: 20rpx;
				height: 55rpx;
				width: 8rpx;
				background-color: #2e45f7;
			}

			.icon-donw {
				display: flex;
				align-items: center;
				margin-right: 38rpx;
				font-size: 30rpx;
				font-weight: bold;
				color: #9aa4ae;
				transition: all .4s ease;
			}

			.up {
				transform: rotate(180deg);
			}
		}

		.main-header-panel-box {
			padding-bottom: 20rpx;
			background-image: url(../../static/images/sy-bg.jpg);
			background-size: 115rpx 115rpx;
			background-repeat: no-repeat;
			background-position: 500rpx 28rpx;

			.hd-inner {
				padding: 20rpx 30rpx;
				border-bottom: none;
			}

			.yellow-text-component {

				.t-yellow {
					margin-right: 30rpx;
					font-size: 44rpx;
				}

				.t-black {
					font-size: 44rpx;
				}

			}

			.panel-bd-inner {
				padding: 16rpx 10rpx 10rpx 26rpx;

				&::after {
					display: none;
				}
			}

			.panel-footer-inner {
				align-items: center;
				justify-content: space-between;

				.icon-text-component {
					flex-basis: auto;
					flex: 1;

					.text {
						font-size: 28rpx;
					}
				}
			}
		}

		.panel-bd-inner {
			padding: 16rpx 10rpx 20rpx 26rpx;
			display: flex;
			justify-content: space-between;
			position: relative;

			&.border-b {
				&::after {
					content: ' ';
					display: block;
					height: 2px;
					background-color: #eee;
					position: absolute;
					bottom: 0;
					left: 28rpx;
					right: 20rpx;

				}
			}


		}

		.panel-footer-inner {
			display: flex;
			flex-wrap: wrap;
			padding: 16rpx 10rpx 10rpx 26rpx;

			.icon-text-component {
				flex-basis: 50%;
			}

			.num {
				margin: 30rpx 0;
				display: block;
				width: 100%;
				font-size: 38rpx;
				color: #666;
			}

			.num-m {
				font-size: 28rpx;
				font-weight: bold;
				color: black;
			}

			.num-bg {
				padding: 10rpx;
				background-color: #26cc84;
				color: white;
				font-size: 26rpx;
				font-weight: bold;
				border-radius: 10rpx;


			}

			.line {
				width: 2px;
				height: 40rpx;
				margin-right: 10rpx;
				background: #ccc
			}
		}

		.icon-text-component {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			color: black;

			.icon {
				margin-right: 14rpx;
				font-size: 40rpx;
				color: #207eef;

			}


			.text {
				font-weight: bold;
				color: #666;
				font-size: 30rpx;
			}

		}

		.yellow-text-component {

			.t-yellow {
				margin-right: 25rpx;
				font-size: 34rpx;
				color: #fb741a;
				font-weight: bold;
			}

			.t-black {
				font-size: 38rpx;
				color: #333;
			}

		}
	}

	.footer-bar {
		display: flex;
		position: fixed;
		padding-top: 20rpx;
		padding-bottom: calc(20rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom)); //兼容 IOS>11.2/
		left: 0;
		right: 0;
		bottom: 0;
		background-color: #181f29;

		.nav-item {
			flex: 1;
			color: white;
			text-align: center;

			.text {
				margin-top: 5rpx;
				display: block;
				width: 100%;
				font-size: 24rpx;
			}

			.nav-icon {
				font-size: 50rpx;
			}

			&.active {
				color: #1695ff;
			}
		}
	}
</style>
